home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
tvg103_s.zip
/
TVGRAPH.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-07-29
|
22KB
|
844 lines
{$A-,B-,D+,E+,F+,G-,I+,L+,N-,O-,R-,S-,V-,X-}
{$M 16384,0,655360}
{$DEFINE DEMO}
unit TvGraph;
(* Include this unit before any other TVision unit and the program will *)
(* Work entirely in graphics mode and look identical ( although slower) *)
(* to the original text display. Using this in conjunction with a *)
(* companion unit TVGOBJ, will allow you to do graphics using the full *)
(* capability of TURBO VISION Menus,Dialog boxes etc. *)
interface
uses
Drivers,Objects,Views;
const
GraphXMax=10000;
GraphYMax=07500;
smEGA = $0010;
smVGA = $0012;
smGraphAutoDetect=$00FF; (* Autodetect *)
wrmOVERWRITE = 0;
wrmAND = 1;
wrmOR = 2;
wrmXOR = 3;
var
GraphMouseLoc:TPoint; (* Graphics location of Mouse *)
type
PGRect=^GRect;
GRect=Trect;
PGPoint=^GPoint;
GPoint=TPoint;
function NextGraphId:byte;
procedure UseGraphId(b:byte);
procedure ReleaseGraphId(b:byte);
procedure TextToGraphics(T:TRect;var G:Grect);
procedure RawDrawLine(X1,Y1,X2,Y2:integer;Color:word);
procedure DrawLine(X1,Y1,X2,Y2:integer;Color:word);
function ISin(X:integer):integer;
function ICos(X:integer):integer;
implementation
const
(********************************************************************)
(* *)
(* CRITICAL - WARNING LOOK AT THIS CONSTANT - VERSION DEPENDANT *)
(* *)
(********************************************************************)
OfsFromInit=$261-$222;
(* Offset between where the Views.Tview.Init procedure is and where *)
(* the code starts for the Checksnow = TRUE code *)
(* This value is absolutely critical and may change between *)
(* Turbovision releases WATCH OUT CRITICAL *)
CurrentGraphWindow:byte=1;
CurrentLineStyle:word=$FFFF;
(* Current Line style in 1=line 0=no line *)
CurrentLineWriteMode:byte=$00;
(* Current Write mode for lines *)
SineTable:array[0..180] of integer=
(0,9,18,27,36,45,54,63,71,80,89,98,107,116,125,134,143,151,160,169,178,
187,195,204,213,222,230,239,248,256,265,274,282,291,299,308,316,325,333,
342,350,359,367,375,384,392,400,408,416,425,433,441,449,457,465,473,481,
489,496,504,512,520,527,535,543,550,558,565,573,580,587,595,602,609,616,
623,630,637,644,651,658,665,672,679,685,692,698,705,711,718,724,730,737,
743,749,755,761,767,773,779,784,790,796,801,807,812,818,823,828,834,839,
844,849,854,859,864,868,873,878,882,887,891,896,900,904,908,912,916,920,
924,928,932,935,939,943,946,949,953,956,959,962,965,968,971,974,977,979,
982,984,987,989,991,994,996,998,1000,1002,1003,1005,1007,1008,1010,1011,
1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1022,1023,1023,1023,
1024,1024,1024,1024);
type
{$IFDEF DEMO}
Vector = record X1,Y1,X2,Y2:word; end;
{$ENDIF}
ABitFont = array[0..255] of array[0..15] of byte;
(* Store upto 32 line high font *)
PAbitFont = ^ABitFont;
(* The pointer to a copy of the currently in use font *)
PtrRec = record O,S:word; end; (* used to separate Ofs and Seg *)
var
(* All the hardware dependant routines called indirectly *)
Do_INIT_X:procedure;
Do_DONE_X:Procedure;
TVGraphCursorOn_X,
TVGraphCursorOff_X,
TVUpdateCursor_X,
Do_GraphMOV_X,
NewJmp_GraphMOV_X:pointer;
Draw_Any_Line_X:procedure (X1,Y1,X2,Y2:word;Color:byte);
Draw_Horiz_Line_X:procedure (X1,X2,Y:word;Color:byte);
Draw_Vert_Line_X:procedure (X,Y1,Y2:word;Color:byte);
P1,P2:Pointer; (* General pointers used for copies *)
BytesPerLine:word; (* Bytes per line in graphics mode *)
VideoBufferSeg:word; (* Video Segment for display *)
GTVEventRoutine:PtrRec;
(* Address of TVision mouse event handler *)
GTVEventMask:word; (* Mask as passed by call to handler install *)
OldINT33h,OldINT10h:Pointer;
(* Old pointers to call for INT 33 and INT 10 *)
Int33h:Pointer absolute $0000:$00CC;
(* INT 33h actual address *)
Int10h:Pointer absolute $0000:$0040;
(* INT 10h actual address *)
RomFont:PABitFont absolute $0000:$010C;
(* Address of current FONT *)
ColorList:word; (* Pointer to List of color masks in EGA memory *)
Count:word; (* Counts down the number of char's in GRAPHMOV *)
DestOfs:word; (* Destination in EGA of the current mask *)
TextSource:PtrRec; (* Source for next Ch/Attr pair *)
TextDest:word; (* Normal destination for text 0..screen size *)
SaveJump:word; (* Save jump location for GraphMov *)
TvGraphLoc,TvGraphCursor:word;
(* Store current text x,y and top/bottom cursor *)
TvViziFlag:byte; (* Toggles ON=FF and OFF=00 for cursor *)
FontTable:ABitFont; (* In Memory font table *)
PtrFontTable:PABitFont;(* Pointer to In Memory font table *)
GraphWriteAvail:array[0..4095] of byte;
(* one byte for each text position on the screen, 0=text screen and *)
(* a number 1-254 representing distinct graphics windows and 255 *)
(* represents the mouse cursor positions *)
GraphIdSet:set of byte;
CharWidth,CharHeight:byte;
(* Width and Height in text mode *)
GraphWidth,GraphHeight:word;
(* Width and height in graphics *)
{$IFDEF DEMO}
DWString:array[1..35] of word; (* Used for text writing *)
const
TVGraphAd:array[1..29] of Vector=
((X1:220;Y1:125;X2:240;Y2:125), (*T2*)
(X1:230;Y1:125;X2:230;Y2:150),
(X1:245;Y1:125;X2:255;Y2:150), (*V2*)
(X1:255;Y1:150;X2:265;Y2:125),
(X1:290;Y1:125;X2:280;Y2:125), (*G7*)
(X1:280;Y1:125;X2:270;Y2:130),
(X1:270;Y1:130;X2:270;Y2:145),
(X1:270;Y1:145;X2:280;Y2:150),
(X1:280;Y1:150;X2:290;Y2:150),
(X1:290;Y1:150;X2:290;Y2:140),
(X1:290;Y1:140;X2:280;Y2:140),
(X1:295;Y1:150;X2:295;Y2:125), (*R6*)
(X1:295;Y1:125;X2:305;Y2:125),
(X1:305;Y1:125;X2:315;Y2:130),
(X1:315;Y1:130;X2:315;Y2:135),
(X1:315;Y1:135;X2:295;Y2:140),
(X1:305;Y1:140;X2:315;Y2:150),
(X1:320;Y1:150;X2:320;Y2:135), (*A5*)
(X1:320;Y1:135;X2:330;Y2:125),
(X1:330;Y1:125;X2:340;Y2:135),
(X1:340;Y1:135;X2:340;Y2:150),
(X1:320;Y1:140;X2:340;Y2:140),
(X1:345;Y1:150;X2:345;Y2:125), (*P4*)
(X1:345;Y1:125;X2:365;Y2:125),
(X1:365;Y1:125;X2:365;Y2:140),
(X1:365;Y1:140;X2:345;Y2:140),
(X1:370;Y1:125;X2:370;Y2:150), (*H3*)
(X1:390;Y1:125;X2:390;Y2:150),
(X1:370;Y1:137;X2:390;Y2:137));
AdvertText:array[1..9] of string[35]=
(' Graphics in TURBOVISION ',
' Copyright 1991 ',
'C.L.Burke of MindWare QLD Australia',
'R.A.Morris of KHIRON QLD Australia ',
' The Wizards of Oz ',
' AND COMING SOON ',
' GWHIZ graphics objects in the ',
' spirit of TurboVision ',
' PRESS ANY KEY TO CONTINUE ');
{$ENDIF}
procedure DisableInterrupts; inline($FA);
procedure EnableInterrupts; inline($FB);
procedure MouseCursorOff;assembler;
asm
mov ax,0002h
cli
pushf
call [OldInt33h]
sti
end;
procedure MouseCursorOn;assembler;
asm
mov ax,0001h
cli
pushf
call [OldInt33h]
sti
end;
{$I TVGRAPH.IN0} (* Display Identify routines *)
{$I TVGRAPH.IN1} (* Display Specific routines *)
{$IFDEF DEMO}
procedure RawWriteString(X,Y:Word;S:String);
const
NormTextColor=$1A00;
var
ScrLoc:word;
Cnt:word;
begin
ScrLoc:=Y*160+X*2;
for Cnt:=1 to 35 do
DWString[Cnt]:=No